package com.ftg.learn.chapter09.listtest;

import java.util.*;

/**
 * 查找List中的最大值和最小值
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/8/16 10:19
 */

public class MaxMin {

    public static void main(String[] args) {

        List<Integer> list= Arrays.asList(1,2,4,3,9,4);
        System.out.println(list);
        int max=0;
        int min=0;
        Set<Integer> set=new HashSet<>(list);
        List<Integer> list1=new ArrayList<>(set);
        min=list1.get(0);
        max=list1.get(list1.size()-1);
        System.out.println("最大："+ max+"最小：" +min);

    }
}
